package cn.hsa.xxx.bookData.dto;


import cn.hsa.xxx.api.dto.BookCommodityDTO;
import cn.hsa.xxx.bookData.entity.BookCommodityDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@Component
public class BookCommodityDTOConverter {

    /**
     * Convert BookCommodityDTO to BookCommodityDO
     *
     * @param bookCommodityDTO
     * @return
     */
    public BookCommodityDO convertToBookCommodityDO(BookCommodityDTO bookCommodityDTO) {
        if (bookCommodityDTO == null) {
            return null;
        }
        BookCommodityDO bookCommodityDO = new BookCommodityDO();

        //BookCommodityDO.setId(BookCommodityDTO.getId());
        //BookCommodityDO.setName(BookCommodityDTO.getName());
        //BookCommodityDO.setSex(BookCommodityDTO.getSex());
        //BookCommodityDO.setAddr(BookCommodityDTO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(bookCommodityDTO, bookCommodityDO);

        return bookCommodityDO;
    }

    /**
     * Convert BookCommodityDO to BookCommodityDTO
     *
     * @param bookCommodityDO
     * @return
     */
    public BookCommodityDTO convertToBookCommodityDTO(BookCommodityDO bookCommodityDO) {
        if (bookCommodityDO == null) {
            return null;
        }

        BookCommodityDTO bookCommodityDTO = new BookCommodityDTO();

        //BookCommodityDTO.setId(BookCommodityDO.getId());
        //BookCommodityDTO.setName(BookCommodityDO.getName());
        //BookCommodityDTO.setSex(BookCommodityDO.getSex());
        //BookCommodityDTO.setAddr(BookCommodityDO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(bookCommodityDO, bookCommodityDTO);

        return bookCommodityDTO;
    }
}
